Merge pull request #396 from knu/show_propagate_immediately

Make propagate_immediately more visible in agent details and the diagram.

Andrew Cantino 10 years ago
parent
commit
ea7594fa97

+ 8 - 0
app/helpers/application_helper.rb

@@ -7,6 +7,14 @@ module ApplicationHelper
7 7
     HTML
8 8
   end
9 9
 
10
+  def yes_no(bool)
11
+    if bool
12
+      '<span class="label label-info">Yes</span>'.html_safe
13
+    else
14
+      '<span class="label label-default">No</span>'.html_safe
15
+    end
16
+  end
17
+
10 18
   def working(agent)
11 19
     if agent.disabled?
12 20
       link_to 'Disabled', agent_path(agent), :class => 'label label-warning'

+ 7 - 1
app/helpers/dot_helper.rb

@@ -36,7 +36,13 @@ module DotHelper
36 36
         end
37 37
         agent.receivers.each do |receiver|
38 38
           next unless agents.include?(receiver)
39
-          dot << "%s->%s;" % [disabled_label(agent), disabled_label(receiver)]
39
+          dot << "%s->%s%s;" % [
40
+            disabled_label(agent),
41
+            disabled_label(receiver),
42
+            if rich
43
+              '[style=dashed]' unless receiver.propagate_immediately
44
+            end
45
+          ]
40 46
         end
41 47
       end
42 48
       dot << "}"

+ 5 - 0
app/views/agents/show.html.erb

@@ -116,6 +116,11 @@
116 116
                   None
117 117
                 <% end %>
118 118
               </p>
119
+
120
+              <p>
121
+                <b>Propagate immediately:</b>
122
+                <%= yes_no @agent.propagate_immediately %>
123
+              </p>
119 124
             <% end %>
120 125
 
121 126
             <% if @agent.can_create_events? %>

+ 1 - 1
spec/helpers/dot_helper_spec.rb

@@ -41,7 +41,7 @@ describe DotHelper do
41 41
         @bar.save!
42 42
 
43 43
         agents_dot([@foo, @bar]).should == 'digraph foo {"foo";"foo"->"bar";"bar";}'
44
-        agents_dot([@foo, @bar], true).should == 'digraph foo {"foo"[URL="/agents/%d"];"foo"->"bar";"bar"[URL="/agents/%d"];}' % [@foo.id, @bar.id]
44
+        agents_dot([@foo, @bar], true).should == 'digraph foo {"foo"[URL="/agents/%d"];"foo"->"bar"[style=dashed];"bar"[URL="/agents/%d"];}' % [@foo.id, @bar.id]
45 45
       end
46 46
     end
47 47
   end